document.addEventListener('DOMContentLoaded', () => {
  const toggleSwitch = document.getElementById('toggleFloatingWindow');

  // 从 storage 中获取开关状态
  chrome.storage.sync.get('floatingWindowOn', (data) => {
    toggleSwitch.checked = data.floatingWindowOn || false;
  });

  toggleSwitch.addEventListener('change', (event) => {
    const isOn = event.target.checked;
    chrome.storage.sync.set({ floatingWindowOn: isOn });
  });
});